<?php


use App\Models\Category;
use Illuminate\Support\Facades\Auth;
use Spatie\Permission\Models\Role;

return [
    'title' => '帖子分类',
    'single' => '帖子分类',
    'model' => Category::class,
    'permission' => function () {
        return Auth::user()->can('manage_users');
    },
    'action_permissions'=>[
        'delete'=>function($model){
            return Auth::user()->hasRole('Founder');
        },
    ],
    'columns' => [
        'id' => [
            'title' => 'ID'
        ],
        'name' => [
            'title' => '帖子分类名称',
            'sortable' => false
        ],
        'description' => [
            'title' => '帖子分类描述',
            'sortable' => false
        ],
        'operation' => [
            'title' => '管理',
            'sortable' => false
        ]
    ],
    'edit_fields' => [
        'name' => [
            'title' => '帖子分类名称'
        ],
        'description' => [
            'title' => '帖子分类描述',
            'type'=>'textarea'
        ],
    ],
    'filters' => [
        'id' => [
            'title' => '分类ID'
        ],
        'name' => [
            'title' => '帖子分类名称'
        ],
        'description' => [
            'title' => '帖子分类描述'
        ],
    ],
    'rules' => [
        'name' => 'required|max:30|unique:categories'
    ],
    'messages' => [
        'name.required'=>'帖子分类不能为空',
        'name.max'=>'帖子分类不能超过30个字',
        'name.unique'=>'帖子分类已存在'
    ]
];
